package com.lgx.mobile.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.lgx.common.entity.IdGenerator;
import com.lgx.right.entity.User;

/**
 * @author xuyichen
 * 
 * 圈子
 *
 */
@Entity
@Table(name = "TM_M_GROUP")
public class Group implements Serializable {
	
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_M_GROUP_ID)
	@TableGenerator(
			name = IdGenerator.TM_M_GROUP_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_M_GROUP_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	/**
	 * 圈子名称
	 */
	private String name;
	
	/**
	 * 圈子描述
	 */
	private String description;
	
	/**
	 * 创建者ID
	 */
	@Column(name = "create_user_id")
	private long createUserId;
	
	/**
	 * 创建时间
	 */
	@Column(name = "create_date")
	private Date createDate;
	
	/**
	 * 圈子分类ID
	 */
	@Column(name = "category_id")
	private long categoryId;
	
	/**
	 * 圈子图片
	 */
	private String groupImage;

	/**
	 * 圈子成员
	 */
	@ManyToMany(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER)    
    @JoinTable(name="TM_M_GROUP_USER",   
             joinColumns=@JoinColumn(name="GROUP_ID"),   
             inverseJoinColumns=@JoinColumn(name="USER_ID"))
	private Set<User> users;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(long createUserId) {
		this.createUserId = createUserId;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(long categoryId) {
		this.categoryId = categoryId;
	}

	public String getGroupImage() {
		return groupImage;
	}

	public void setGroupImage(String groupImage) {
		this.groupImage = groupImage;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}
}
